import Tit from '../../components/Tit'
import React from 'react'
import { withRouter } from 'react-router-dom'
import Address from '../../components/Address'
import './AllAddress.less'
class AllAddress extends React.Component {
    state = {
        AllAddress: null
    }
    componentDidMount() {
        this.$postData('/api/address/getAddressList', {}, params => {
            console.log(params)
            switch (params.code) {
                case 100:
                    this.setState({
                        AllAddress: params.data
                    })
                    break;
                default:
                    this.Toast.info(params.msg);
                    break;
            }
        })
    }
    AddAddress(val) {
        this.props.history.push(`/AddAddress/${val}`)
    }
    render() {
        return (
            <div className='FillO-page Address-white'>
                <Tit tit={'地址管理'} zz={false}></Tit>
                {this.state.AllAddress ? this.state.AllAddress.map((val, index) => (
                    <Address ID={1} index={index} key={val.id} address={val}></Address>
                )) : <div></div>}
                <p className='center Address-bottom' onClick={this.AddAddress.bind(this, 'null')}>
                    新建地址
                </p>
            </div>
        )
    }
}

export default withRouter(AllAddress)